<template>
	<div :id="id" class="badgeWhite baseContent" v-if="dataRend" v-loading="active">
		<basetitle>
			<slot slot="left">
				<b>{{ dataRend.name }}</b>
			</slot>
			<slot slot="right">
				<div class="rightFontCont"><i class="iconfont icon-shuaxin1 rightFont" @click="refreshFull(dataRend.prn)"></i></div>
			</slot>
		</basetitle>
		<div class="baseCont">
			<div class="overHideen chartContent" :style="{ height: dataRend.itemData.height != '' ? dataRend.itemData.height : defalutHeight }">
				<ring-charts :centerData="dataRend.itemData.centerTextData" :centerText="dataRend.itemData.centerText" :itemdata="dataRend.itemData" :id="chartId"/>
			</div>
		</div>
	</div>
</template>
<script>
import { generateMixed } from '@/utils/index.js';
const basetitle =()=>import('@/components/basetitle/index.vue')//
const CircularCharts2 =()=>import('@/components/Charts/CircularCharts2.vue')//仪表盘
const RingCharts =()=>import('@/components/Charts/RingCharts.vue')//环形统计
const veRadar =()=>import('@/components/Charts/veRadar.vue')//环形统计
const PieChart =()=>import('@/components/Charts/PieChart.vue')//嵌套统计
import store from '../../../store';
import { mapState, mapActions } from 'vuex';
import { getHomePage, refreshContent } from '../../../api/config.js';
import { getFromCache } from '@/utils/cache.js';
export default {
	name: 'JiuList',
	mixins: [],
	props: {
		className: {
			type: String,
			default: 'baseId' + generateMixed('8')
		},
		id: {
			type: String,
			default: 'baseId' + generateMixed('8')
		},
		width: {
			type: String,
			default: '200px'
		},
		defalutHeight: {
			type: String,
			default: '300px'
		},
		itemdata: {
			default: Object
		},
		itemStyle: {
			default: Object
		}
	},
	components: {
		basetitle,
		CircularCharts2,
		RingCharts,
		veRadar,
		PieChart
	},
	data() {
		return {
			dataRend: {},
			active: false,
      chartId:'chart' + generateMixed('8')
		};
	},
	beforeDestroy() {

	},
	created: function () {
		this.dataRend = this.itemdata;
	},
	mounted() {

	},
	methods: {
		...mapActions('base', ['getIndexRend']),
		refreshFull(type) {
			let that = this;
			that.active = true;
			let parms = {};
			parms.type = type;
      parms.user_prn = JSON.parse(getFromCache('userInfo')).env$user_prn;
			that.$post(refreshContent, parms).then(response => {
				setTimeout(function() {
					that.active = false;
				}, 2000);
				if (response.status === false) {
					that.$message.error(response.error[0]);
					return;
				}
				that.dataRend = response.obj;
			});
		}
	},
	watch: {
		mainRend() {
			this.dataRend = this.mainRend;
		}
	}
};
</script>

<style></style>
